package leetcode.LinkedList;

/**
 * @author wangmaolin1
 * @date 2023/11/2 12:18
 */
public class _83删除排序链表中的重复元素 {
    public static ListNode deleteDuplicates(ListNode head) {
        if (head==null){
            return  null;
        }
        ListNode slow = head;
        ListNode fast = head;
        while (fast!=null){
            if (fast.val != slow.val){
                slow.next = fast;
                slow = slow.next;
            }
            fast= fast.next;

        }
        slow.next= null;
        return  head;
    }

    public static void main(String[] args) {
        ListNode head =new ListNode(1,new ListNode(1));
        ListNode listNode = deleteDuplicates(head);
        System.out.println(listNode);
    }
}
